Skip to content

fix: YearTransform return years since 1970#495

Merged
wgtmac merged 2 commits intoapache:mainfrom
WZhuo:transform_util
Jan 8, 2026
Merged

fix: YearTransform return years since 1970#495
wgtmac merged 2 commits intoapache:mainfrom
WZhuo:transform_util

Conversation

@WZhuo
Copy link
Copy Markdown
Contributor

@WZhuo WZhuo commented Jan 7, 2026

No description provided.

@WZhuo
Copy link
Copy Markdown
Contributor Author

WZhuo commented Jan 7, 2026

   Types.TimestampType type = Types.TimestampType.withoutZone();
    Literal<Long> ts = Literal.of("2017-12-01T10:12:55.038194").to(type);
    Literal<Long> pts = Literal.of("1970-01-01T00:00:01.000001").to(type);
    Literal<Long> nts = Literal.of("1969-12-31T23:59:59.999999").to(type);

    Transform<Long, Integer> years = Transforms.year();
    assertThat((int) years.bind(type).apply(ts.value()))
        .as("Should produce 2017 - 1970 = 47")
        .isEqualTo(47);
    assertThat((int) years.bind(type).apply(pts.value()))
        .as("Should produce 1970 - 1970 = 0")
        .isZero();
    assertThat((int) years.bind(type).apply(nts.value()))
        .as("Should produce 1969 - 1970 = -1")
        .isEqualTo(-1);

Above is the YearTransform's test case in Java, it should return delta years between the time and 1970.

@zhjwpku
Copy link
Copy Markdown
Collaborator

zhjwpku commented Jan 7, 2026

Good catch, you may also want to change the comments of Transform::Year() and YearTransform.

Comment thread src/iceberg/transform_function.h
@WZhuo WZhuo changed the title fix: YearTransform return delta years from 1970 fix: YearTransform return years since 1970 Jan 8, 2026
@wgtmac wgtmac merged commit 40834dd into apache:main Jan 8, 2026
10 checks passed
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented Jan 8, 2026

Thanks @WZhuo for fixing this and @zhjwpku for the review!

@WZhuo WZhuo deleted the transform_util branch February 11, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants